// // 1.基本数据类型
// // 字符串
// let name1 : string = "张三";
// let message: string = `Hello, ${name1}!`;
// // 数字
// let age: number = 25;
// let price: number = 99.99;
// let binary: number = 0b1010;
// // 布尔值
// let isActive: boolean = true;
// let isCompleted: boolean = false;
// // null 和 undefined
// let empty: null = null;
// let notDefined: undefined = undefined;
// 2.数组类型
// 两种声明方式
var numbers = [1, 2, 3, 4];
var strings = ["a", "b", "c"];
console.log(numbers);
console.log(strings);
// 只读数组
var readonlyArray = [1, 2, 3];
//3.元组类型
var person = ["张三", 25];
var rgb = [255, 0, 0];
// 可选元组元素
var optionalTuple = ["李四"];
var user = {
    name: "王五",
    age: 30
};
//5.枚举类型
// 数字枚举
var Direction;
(function (Direction) {
    Direction[Direction["Up"] = 1] = "Up";
    Direction[Direction["Down"] = 2] = "Down";
    Direction[Direction["Left"] = 3] = "Left";
    Direction[Direction["Right"] = 4] = "Right";
})(Direction || (Direction = {}));
// 字符串枚举
var Color;
(function (Color) {
    Color["Red"] = "RED";
    Color["Green"] = "GREEN";
    Color["Blue"] = "BLUE";
})(Color || (Color = {}));
//6. 任意类型
var uncertain = "可以是任意类型";
uncertain = 42;
uncertain = true;
//7. 未知类型
var notSure = "需要类型检查";
// notSure.toFixed(); // 错误：需要类型断言
if (typeof notSure === "number") {
    notSure.toFixed(); // 正确
}
// 8. 空类型和无返回类型
// void - 没有返回值
function logMessage() {
    console.log("Hello");
}
// never - 永远不会返回结果
function throwError(message) {
    throw new Error(message);
}
function infiniteLoop() {
    while (true) { }
}
//9. 联合类型
var id = "abc123";
id = 123;
function printId(id) {
    console.log("ID: ".concat(id));
}
var person1 = {
    name: "赵六",
    age: 28
};
var move = "up";
var roll = 6;
var isTrue = true;
var add = function (x, y) { return x + y; };
function reverse(value) {
    if (typeof value === "string") {
        return value.split("").reverse().join("");
    }
    return Number(value.toString().split("").reverse().join(""));
}
//13. 泛型
// 泛型函数
function identity(arg) {
    return arg;
}
// 泛型类
var GenericNumber = /** @class */ (function () {
    function GenericNumber() {
    }
    return GenericNumber;
}());
//类型断言
// 两种语法
var someValue = "这是一个字符串";
var strLength1 = someValue.length;
var strLength2 = someValue.length;
